﻿/****************************************************************
*   作者：Morain
*   创建时间：2018/2/23 19:44:02
*   描述说明：
*****************************************************************/
using Model;
using System.Net;
namespace Hotfix
{
  [ObjectSystem]
  public class NetOuterComponentSystem : ObjectSystem<NetOuterComponent>, IAwake, IAwake<IPEndPoint>, IUpdate
  {
    public void Awake(IPEndPoint p)
    {
      Get().Awake(p);
    }

    public void Awake()
    {
      Get().Awake();
    }

    public void Update()
    {
      Get().Update();
    }
  }

  public static class NetOuterComponentEx
  {
    public static void Awake(this NetOuterComponent self)
    {
      self.Awake(NetworkProtocol.TCP);
      self.MessagePacker = new ProtobufPacker();
      self.MessageDispatcher = new OuterMessageDispatcher();
    }

    public static void Awake(this NetOuterComponent self, IPEndPoint iPEndPoint)
    {
      self.Awake(NetworkProtocol.TCP, iPEndPoint);
      self.MessagePacker = new ProtobufPacker();
      self.MessageDispatcher = new OuterMessageDispatcher();
    }

    public static void Update(this NetOuterComponent self)
    {
      self.Update();
    }
  }
}